//tbTask.modify.vue
<template>
  <el-form
      ref="formref"
      :model="formData"
      label-width="auto"
      :inline="true"
  >

    <el-form-item
        label="id" prop="id" align="center">
      <div slot="label"><span>id</span></div>
      <el-input v-model="formData['id']"
                clearable size="mini" style="width:120px" />
    </el-form-item>
    <el-form-item
        label="name" prop="name" align="center">
      <div slot="label"><span>name</span></div>
      <el-input v-model="formData['name']"
                clearable size="mini" style="width:120px" />
    </el-form-item>
    <el-form-item
        label="content" prop="content" align="center">
      <div slot="label"><span>content</span></div>
      <el-input v-model="formData['content']"
                clearable size="mini" style="width:120px" />
    </el-form-item>


    <el-form-item
        label="planstarttime" prop="planstarttime" align="center">
      <div slot="label"><span>planstarttime</span></div>

      <erp-date-picker v-model="formData['planstarttime']"
                       clearable size="mini" style="width:130px" />
    </el-form-item>
    <el-form-item
        label="planendtime" prop="planendtime" align="center">
      <div slot="label"><span>planendtime</span></div>
      <erp-date-picker v-model="formData['planendtime']"
                clearable size="mini" style="width:120px" />
    </el-form-item>
    <el-form-item
        label="realstarttime" prop="realstarttime" align="center">
      <div slot="label"><span>realstarttime</span></div>
      <erp-date-picker v-model="formData['realstarttime']"
                clearable size="mini" style="width:120px" />
    </el-form-item>
    <el-form-item
        label="realendtime" prop="realendtime" align="center">
      <div slot="label"><span>realendtime</span></div>
      <erp-date-picker v-model="formData['realendtime']"
                clearable size="mini" style="width:120px" />
    </el-form-item>
    <el-form-item
        label="state" prop="state" align="center">
      <div slot="label"><span>state</span></div>
      <el-input v-model="formData['state']"
                clearable size="mini" style="width:120px" />
    </el-form-item>


  </el-form>
</template>
<script>
import erpDatePicker from '@/views/components/erpDatePicker/erpDatePicker.vue';
import axios from 'axios';
import { formData, formMethod, PageData, uniqWithKey } from '@/utils/formcommon';
import { openLayer } from '@/utils/layerdialog/layerdialog';
import { alertConfirm, alertWithPayload } from '@base/utils';
import { lodashFillData } from '@/utils/lodashUtil';
import { tbTask } from '@/views/manage/tbtask/tbTask.json';

export default {
  data() {
    return {
      total: 0,
      formData: {
        ...tbTask,
        ...PageData,
      },
    };
  },
  components: {
    erpDatePicker,
  },
  methods: {
    ...formMethod,
    async initByDialog(_data) {
      if (_data?.row?.id) {
        var result = await axios.get(`/api/tb_task/getbyid?id=${_data?.row?.id}`, { ...this.queryParams }).then(res => res.data);
        var _data2 = result?.data;
        lodashFillData(this.formData, _data2);
        console.log('=>[_data2]', _data2);
      }
    },
    async submitByDialog() {
      //validate
      //data operation
      //ajax 提交
      var url = '/api/tb_task/add';
      if (this.formData?.id) {
        url = '/api/tb_task/update';
      }
      var result = await axios.post(url, { ...this.formData }).then(res => res.data);
      alertWithPayload(result);
      return result;
    },
  },
};
</script>
